package com.zdsoft.blp.zongbuju.shouye.linliquan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.zdsoft.blp.R;
import com.zdsoft.blp.gongyong.imageTrans.CircleImage;
import com.zdsoft.blp.zongbuju.shouye.wuye.entity.WuYe;
import com.zdsoft.blp.zongbuju.shouye.wuye.entity.XiangQing;

import java.util.List;

/**
 * Created by Administrator on 2016/8/31.
 */
public class LinLiQuanAdapter extends BaseAdapter {

    private List<WuYe> list;
    private Context context;
    private LayoutInflater inflater;

    public LinLiQuanAdapter(List<WuYe> list, Context context) {
        this.list = list;
        this.context = context;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHorld horld=null;
        if (view==null){
            horld=new ViewHorld();
            view= inflater.inflate(R.layout.linli_gv_item,null);
            horld.linli_iv_item= (ImageView) view.findViewById(R.id.linli_iv_item);
            horld.lin_tv_item= (TextView) view.findViewById(R.id.lin_tv_item);
            view.setTag(horld);
        }else {
            horld= (ViewHorld) view.getTag();
        }
        WuYe wuYe=list.get(i);
        Picasso.with(context).load(wuYe.getImgPath()).transform(new CircleImage()).error(R.drawable.no_pic).placeholder(R.drawable.loading).into(horld.linli_iv_item);
        horld.lin_tv_item.setText(wuYe.getTitle());
        return view;
    }
    class ViewHorld{
        ImageView linli_iv_item;
        TextView lin_tv_item;
    }
}
